package com.sunwayhorizo.health.common;

import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
import org.jboss.seam.Component;

public class ValidateInterceptor {
	@AroundInvoke
	public Object validateDTO(InvocationContext invocation) throws Exception {
		ValidateUtilLocal validateUtil = (ValidateUtilLocal) Component
				.getInstance("ValidateUtil");
	
		for (Object o : invocation.getParameters()) {
			System.out.println(o.getClass().getSimpleName());
			if (o.getClass().getSimpleName().endsWith("DTO")) {
				if (!validateUtil.verified(o)) {
					System.out.println("验证失败！");
				}
			}
		}
		return invocation.proceed();

	}
}
